package LeetCode.leetcode155

import java.util.ArrayDeque

class MinStack {
    val minStack = ArrayDeque<Int>()
    val numsStack = ArrayDeque<Int>()
    constructor(){
        minStack.push(Integer.MAX_VALUE)
    }

    fun push(`val`: Int) {
        numsStack.push(`val`)
        minStack.push(Math.min(minStack.peek(), `val`))
    }

    fun pop() {
        numsStack.pop()
        minStack.pop()
    }

    fun top(): Int {
        return numsStack.peek()
    }

    fun getMin(): Int {
        return minStack.peek()
    }
}